{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from facebook import *\n",
    "from utils import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "user_name = \"qiao3014659@gmail.com\"\n",
    "password = \"qiao13593537918\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "fb = Facebook(user_name, password)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "fb.sign_in()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "fb.make_post()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "my name: Qiao Fengchun\n",
      "my id: 100012127725531\n",
      "my homepage url: https://www.facebook.com/qiao.fengchun\n"
     ]
    }
   ],
   "source": [
    "fb.get_myself_info()\n",
    "print(\"my name: %s\" % fb.user_name)\n",
    "print(\"my id: %s\" % fb.user_id)\n",
    "print(\"my homepage url: %s\" % fb.homepage_url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "fb.get_friends_number()\n",
    "print(fb.friends_number)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['周明星', '100022483429126', 'https://www.facebook.com/profile.php?id=100022483429126']\n",
      "['Yijie Dong', '100008203770893', 'https://www.facebook.com/profile.php?id=100008203770893']\n"
     ]
    }
   ],
   "source": [
    "fb.get_friends_list(3)\n",
    "for friend in fb.user_info_friends:\n",
    "    print(friend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "user_list = fb.search_users(\"12345678910010101\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "print(user_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['你好', 100000031380685, 'https://www.facebook.com/profile.php?id=100000031380685&ref=br_rs', None]\n",
      "['吳純如', 100006711912986, 'https://www.facebook.com/profile.php?id=100006711912986&ref=br_rs', '天天開心 享受人生 有限公司']\n",
      "['Nihao Mexico (你好)', 1818561726, 'https://www.facebook.com/nihaomexico?ref=br_rs', 'nihao 你好']\n",
      "['薛雅心', 100008939044587, 'https://www.facebook.com/profile.php?id=100008939044587&ref=br_rs', '天天開心 享受人生 有限公司']\n",
      "['Santini Nihao', 100000655383263, 'https://www.facebook.com/santini.khang?ref=br_rs', 'Jakarta, Indonesia']\n"
     ]
    }
   ],
   "source": [
    "users_list1 = fb.search_users(\"你好\", 5)\n",
    "for user in users_list1:\n",
    "    print(user)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.facebook.com/photo.php?fbid=443127046101549&set=pb.100012127725531.-2207520000.1523986897.&type=3&size=288%2C163\n",
      "https://www.facebook.com/photo.php?fbid=439894299758157&set=pb.100012127725531.-2207520000.1523986897.&type=3&size=960%2C632\n",
      "https://www.facebook.com/photo.php?fbid=439891943091726&set=pb.100012127725531.-2207520000.1523986897.&type=3&size=200%2C200\n",
      "https://www.facebook.com/photo.php?fbid=439884959759091&set=pb.100012127725531.-2207520000.1523986897.&type=3&size=1366%2C768\n",
      "https://www.facebook.com/photo.php?fbid=439872593093661&set=pb.100012127725531.-2207520000.1523986897.&type=3&size=1200%2C675\n"
     ]
    }
   ],
   "source": [
    "photos_list = fb.get_photos_href_list(fb.homepage_url)\n",
    "for link in photos_list:\n",
    "    print(link)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['https://scontent-nrt1-1.xx.fbcdn.net/v/t1.0-9/30704408_443127049434882_4689523294120968192_n.jpg?_nc_cat=0&oh=c112a4a0cea8c807797a59b762210385&oe=5B68EECB', '1523929098', None, [], '288', '163']\n",
      "['https://scontent-nrt1-1.xx.fbcdn.net/v/t1.0-9/30441634_439894306424823_9215412362943660032_n.jpg?_nc_cat=0&oh=4b404404328b89fa839fae3f9d36761b&oe=5B625676', '1523189480', None, [], '960', '632']\n",
      "['https://scontent-nrt1-1.xx.fbcdn.net/v/t1.0-9/30262108_439891946425059_5833125432660066304_n.jpg?_nc_cat=0&oh=c452aa1bb679c5508ac370da36e08422&oe=5B72A1D5', '1523189430', None, [], '200', '200']\n",
      "['https://scontent-nrt1-1.xx.fbcdn.net/v/t1.0-9/30262069_439884963092424_1605344151157604352_o.jpg?_nc_cat=0&oh=06794cdf2292c4c67288e245bbdefcf3&oe=5B73B729', None, None, [], '1366', '768']\n",
      "['https://scontent-nrt1-1.xx.fbcdn.net/v/t1.0-9/30412268_439872596426994_8140207024542580736_o.jpg?_nc_cat=0&oh=5d35af93f28a5db10419c592851ef4b2&oe=5B5C1F78', '1523186366', None, 'hhhhhhh', '1200', '675']\n"
     ]
    }
   ],
   "source": [
    "info_list = fb.get_photos_info_list(photos_list)\n",
    "for info in info_list:\n",
    "    print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "image 30704408_443127049434882_4689523294120968192_n.jpg is saved successfully.\n",
      "image 30441634_439894306424823_9215412362943660032_n.jpg is saved successfully.\n",
      "image 30262108_439891946425059_5833125432660066304_n.jpg is saved successfully.\n",
      "image 30262069_439884963092424_1605344151157604352_o.jpg is saved successfully.\n",
      "image 30412268_439872596426994_8140207024542580736_o.jpg is saved successfully.\n"
     ]
    }
   ],
   "source": [
    "fb.download_photos_one(fb.homepage_url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "full_screen_element = fb.driver.find_element_by_id(\"fbPhotoSnowliftFullScreenSwitch\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<selenium.webdriver.remote.webelement.WebElement (session=\"813456d8eca267da606886110d139a23\", element=\"0.84575782581803-1\")>\n"
     ]
    }
   ],
   "source": [
    "print(full_screen_element)\n",
    "full_screen_element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['你好', 100000031380685, 'https://www.facebook.com/profile.php?id=100000031380685&ref=br_rs', None]\n"
     ]
    }
   ],
   "source": [
    "print(users_list1[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
